<style lang="scss">
  @import 'index';
</style>

<template>
  <div class="ga-container">
    <div class="ga-sales">
      <div class="head-box">
        <image class="img-box" mode="aspectFill" :src="User.avatarUrl"></image>
        <p class="p1">{{User.nickName}}</p>
        <p class="p2" @click="previewImage">我的推荐码</p>
      </div>
      <!-- <div class="head-box">
        <image class="img-box" :src="User.avatarUrl" @tap="previewImage"></image>
      </div> -->

      <ul class="menu-box">
        <li>
          <div class="item">
            <p class="p1">{{month}}<span>元</span></p>
            <p class="p2 gBlue">当月佣金</p>
          </div>
        </li>
        <li>
          <div class="item">
            <p class="p1">{{total}}<span>元</span></p>
            <p class="p2 gBlue">累计佣金</p>
          </div>
        </li>
      </ul>
      <ul class="menu-box mt10">
        <li>
          <a href="/pages/teams/main" class="item link1">
            <p class="p1">我的团队</p>
            <p class="p2 gGraylight">{{teamcount}}人</p>
          </a>
        </li>
        <li>
          <a href="/pages/commission/main" class="item link2">
            <p class="p1">佣金明细</p>
            <p class="p2 gGraylight">佣金提现明细</p>
          </a>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import {isLogin} from '@/utils/handleLogin'
export default {

  data () {
    return {
       User: {},
       teamcount: 0,
       month: '0.00',
       total: '0.00'
    }
  },
  methods: {
    async load () {
      /*获取团队人数*/
      this.$_util.ajax.post('https://guo-a.com/mapi/user/userteam?token=' + this.$store.state.Token).then((res)=>{
        if(res.code === 200){
          this.teamcount = res.data.total
        }
      })
      /*获取佣金信息*/
      this.$_util.ajax.post('https://guo-a.com/mapi/user/useraccount?token=' + this.$store.state.Token).then((res)=>{
         if(res.code === 200){
          this.month = res.data.month
          this.total = res.data.total
         }
      })
    },
    previewImage () {
      let that = this
      wx.previewImage({
          urls: ['https://guo-a.com/mapi/user/sharecode?token='+that.$store.state.Token] // 需要预览的图片http链接列表
      })
    }
  },

  created () {

  },
  onShow () {
    isLogin(()=>{
       this.User = this.$store.state.WxUser
       this.load()
    })
  },
  mounted () {

  }
}
</script>
